
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login</title>

<link href="{#WWW}View/hy_user/css/login.css" rel="stylesheet">
<link href="{#WWW}public/css/alert.css" rel="stylesheet">
<script src="{#WWW}public/js/jquery.min.js"></script>
<script src="{#WWW}public/js/sweet-alert.min.js"></script>

</head>
<body>

	<div class="main">
		<div class="login-form">
			<h1>用户登录</h1>
			<div class="head"><img id="img" src="{#WWW}View/hy_user/css/user.png" alt=""/></div>
			<form id="form">
				{hook t_user_login_1}
				<input type="text" id="user" name="user" class="text" value="" placeholder="Username"/>
				<input type="password" name="pass" value="" placeholder="Password"/>
				{hook t_user_login_2}
				<div class="submit">
					<input id="login" type="submit" value="登录" >
				</div>
				{hook t_user_login_3}
				<p><a href="{#WWW}user{#EXP}add">注册账号 | </a> <a href="#">忘记密码?</a></p>
				{hook t_user_login_4}
			</form>
		</div>

	</div>

<script>
$(function(){

	$("#user").blur(function(){
		$.get("{#WWW}ajax{#EXP}useravatar",{user:$(this).val()},function(e){
			$("#img").attr('src',"{#WWW}"+e.b)
		},'json');
	})


    $('#form').submit(function() {return false;});

    $("#login").click(function(){
        var postdata = $('#form').serialize();
        $.post("{#WWW}user{#EXP}login", postdata,  function(e){
            swal(e.error ? "登录成功 - 正在为你跳转" : "登录失败", e.info, e.error ? "success" : "error");
            if(e.error){
                setTimeout(function(){
                    window.location.href="{#WWW}";
                },2000);
            }

        },'json');
    })




});
</script>
</body>
</html>
